package advert_api

import (
	"github.com/gin-gonic/gin"
	"gvb_server/models"
	"gvb_server/models/res"
	"gvb_server/service/common"
)

// AdvertList 分页查询广告
// @Tags 广告管理
// @Summary 分页查询广告
// @Description 分页查询广告
// @Param data query models.Page false "查询参数"
// @Router /api/advert [get]
// Produce json
// @Success 200 {object} res.Response{data=res.PageResponse[models.AdvertModel]}
func (AdvertApi) AdvertList(c *gin.Context) {
	var page models.Page
	err := c.ShouldBindQuery(&page)
	if err != nil {
		res.FailCode(res.ArgumentError, c)
		return
	}
	list, count := common.Page(&models.AdvertModel{}, page)
	res.OKWithPage(list, count, c)
}
